import Matter from "src/matter/entities/matter.entity";
import User from "src/user/entities/user.entity";
import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, Tree, TreeChildren, TreeParent, UpdateDateColumn } from "typeorm";

@Entity()
@Tree("closure-table")
export default class Dept {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @Column()
  deptName: string;

  @TreeChildren()
  children: Dept[];

  @TreeParent()
  parent: Dept;

  @OneToMany(() => Matter, matter => matter.dept)
  matters: Matter[]

  @OneToMany(() => User, user => user.dept)
  users: User[];

  @CreateDateColumn()
  createdDate: Date;

  @UpdateDateColumn()
  updatedDate: Date;
}